// 石墨化
<template>
  <div class="container card">
    <el-tabs v-model="graActiveName" type="card" @tab-click="handleClick">
      <el-tab-pane label="用户质量要求表" name="qualityRequire">
        <qualityRequire v-if="qualityRequire" />
      </el-tab-pane>
      <el-tab-pane label="装（出）炉报告" name="inFurnace">
        <inFurnace v-if="inFurnace" />
      </el-tab-pane>
      <el-tab-pane label="送电曲线" name="giveElectric">
        <giveElectric v-if="giveElectric" />
      </el-tab-pane>
      <el-tab-pane label="送电记录表（基本信息）" name="basicInfo">
        <basicInfo v-if="basicInfo" />
      </el-tab-pane>
      <el-tab-pane label="送电记录表（详细信息）" name="minuteInfo">
        <minuteInfo v-if="minuteInfo" />
      </el-tab-pane>
      <el-tab-pane label="产品信息" name="productInfo">
        <productInfo v-if="productInfo" />
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
// 记录问题 每次进入标签页都会对所有标签页发起请求 通过tab.index和v-if解决
// import Bus from '@/utils/bus.js'
import qualityRequire from './qualityRequire'
import inFurnace from './inFurnace'
import giveElectric from './giveElectric'
import basicInfo from './basicInfo'
import productInfo from './productInfo'
import minuteInfo from './minuteInfo'
export default {
  name: '',
  components: {
    qualityRequire,
    inFurnace,
    giveElectric,
    basicInfo,
    minuteInfo,
    productInfo
  },
  props: {},
  data () {
    return {
      graActiveName: 'qualityRequire',
      qualityRequire: true,
      inFurnace: false,
      giveElectric: false,
      basicInfo: false,
      minuteInfo: false,
      productInfo: false
    }
  },
  computed: {},
  watch: {},
  beforeCreate () { },
  created () {
    // 接参数
    // this.activated()

    // 判断缓存里有没有activeName 有的话再走缓存 没的话默认第一页
    if (sessionStorage.getItem('graActiveName')) {
      this.graActiveName = sessionStorage.getItem('graActiveName')
      // console.log(this[this.activeName])
      switch (sessionStorage.getItem('graActiveName')) {
        case 'qualityRequire':
          this.qualityRequire = true
          this.inFurnace = false
          this.giveElectric = false
          this.basicInfo = false
          this.minuteInfo = false
          this.productInfo = false
          break
        case 'inFurnace':
          this.qualityRequire = false
          this.inFurnace = true
          this.giveElectric = false
          this.basicInfo = false
          this.minuteInfo = false
          this.productInfo = false
          break
        case 'giveElectric':
          this.qualityRequire = false
          this.inFurnace = false
          this.giveElectric = true
          this.basicInfo = false
          this.minuteInfo = false
          this.productInfo = false
          break
        case 'basicInfo':
          this.qualityRequire = false
          this.inFurnace = false
          this.giveElectric = false
          this.basicInfo = true
          this.minuteInfo = false
          this.productInfo = false
          break
        case 'minuteInfo':
          this.qualityRequire = false
          this.inFurnace = false
          this.giveElectric = false
          this.basicInfo = false
          this.minuteInfo = true
          this.productInfo = false
          break
        case 'productInfo':
          this.qualityRequire = false
          this.inFurnace = false
          this.giveElectric = false
          this.basicInfo = false
          this.minuteInfo = false
          this.productInfo = true
          break
        default:
          console.log('出错了')
          break
      }
    }
  },
  beforeDestroy () {
    // Bus.$off('activeName')
    sessionStorage.setItem('graActiveName', 'qualityRequire')
  },
  mounted () { },
  methods: {
    handleClick (tab, event) {
      // console.log(tab.index, event)
      switch (tab.index) {
        case '0':
          this.qualityRequire = true
          this.inFurnace = false
          this.giveElectric = false
          this.basicInfo = false
          this.minuteInfo = false
          this.productInfo = false
          break
        case '1':
          this.qualityRequire = false
          this.inFurnace = true
          this.giveElectric = false
          this.basicInfo = false
          this.minuteInfo = false
          this.productInfo = false
          break
        case '2':
          this.qualityRequire = false
          this.inFurnace = false
          this.giveElectric = true
          this.basicInfo = false
          this.minuteInfo = false
          this.productInfo = false
          break
        case '3':
          this.qualityRequire = false
          this.inFurnace = false
          this.giveElectric = false
          this.basicInfo = true
          this.minuteInfo = false
          this.productInfo = false
          break
        case '4':
          this.qualityRequire = false
          this.inFurnace = false
          this.giveElectric = false
          this.basicInfo = false
          this.minuteInfo = true
          this.productInfo = false
          break
        case '5':
          this.qualityRequire = false
          this.inFurnace = false
          this.giveElectric = false
          this.basicInfo = false
          this.minuteInfo = false
          this.productInfo = true
          break
        default:
          console.log('出错了')
          break
      }
    }
    // 每次激活时
    // activated () {
    //   var vm = this
    //   // 根据key名获取传递回来的参数，data就是map
    //   Bus.$on('activeName', data => {
    //     // 赋值给当前页面的值
    //     console.log('data', data)
    //     vm.activeName = data
    //   })
    //   console.log('this.activeName', this.activeName)
    // }
  }
}
</script>

<style scoped lang="">
</style>
